home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / 5tinydms / poly4.s < prev    next >
Text File  |  1995-12-05  |  14KB  |  960 lines

  1.  
  2. ********************************************
  3. *                           *
  4. *  Lame generic gouraud routine               *
  5. *  Not optimized at all - Just for sample  *
  6. *  (C)oderight 1995 by Jedi/Sector One     *
  7. *                       *
  8. ********************************************
  9.  
  10. !faraway    set 900
  11.  
  12.     org $100
  13.  
  14. ; flat real mode
  15.  
  16.     d+
  17.     move cs,a
  18.     move a,ds
  19.     move a,es
  20.     add #@stack,a
  21.     move a,ss
  22.     bsr initFRM
  23.  
  24. ; 320x200 / 256
  25.  
  26.     move #$13,a
  27.     trap #$10
  28.  
  29. ;    bsr xmode
  30.  
  31. ; cls
  32.  
  33.     move #$a000,a
  34.     move a,es
  35.     xor a,a
  36.     xor di,di
  37.     move #320*200/2-1,c
  38.     rep:stos
  39.  
  40.     push ds
  41.     push es
  42.  
  43.     xor di,di
  44.     move cs,a
  45.     add #@bkg,a
  46.     move a,es
  47.     move #100,d
  48.     move #160,bp
  49. .loop2    move bp,c
  50.     xor.b a,a
  51.     rep:stos.b
  52.     move.b #128,a
  53.     move bp,c
  54.     rep:stos.b
  55.     dec d
  56.     bne.s .loop2
  57.     move #100,d
  58. .loop2    move bp,c
  59.     move.b #128,a
  60.     rep:stos.b
  61.     xor.b a,a
  62.     move bp,c
  63.     rep:stos.b
  64.     dec d
  65.     bne.s .loop2
  66.  
  67.     pop es
  68.     pop ds
  69.  
  70. ; that's the way I like it
  71.  
  72.     move cs,a
  73.     move a,ds
  74.     move a,es
  75.  
  76. ; Clear the virtual screen
  77.  
  78.     move.l #pchouk,be
  79.     move #[pchoukf-pchouk]/4,c
  80.     xor.l ae,ae
  81. .loop    move.l ae,(be)
  82.     add.l #4,be
  83.     dbf .loop
  84.  
  85. ; Add the bottom border
  86.  
  87.     move.l #pchouk+320*200,be
  88.     move #320,c
  89.     move.b #-1,a
  90. .loop    move.b a,(be)
  91.     inc.l be
  92.     dbf .loop
  93.  
  94. ; Generate a fade table
  95.  
  96.     move.l #fadetable+5,be
  97.     move #251,c
  98.     xor.b a,a
  99.     move.b a,-1(be)
  100.     move.b a,-2(be)
  101.     move.b a,-3(be)
  102.     move.b a,-4(be)
  103.     move.b a,-5(be)
  104. .loop    move.b a,(be)
  105.     inc.b a
  106.     inc.l be
  107.     dbf .loop
  108.  
  109. ; Some great colors
  110.  
  111.     move #$3c8,d
  112.     xor.b a,a
  113.     out.b a,d
  114.     inc d
  115.     move.b #8,b
  116.     move #64,c
  117.     move c,bp
  118.     sub #8,c
  119. .loop    xor.b a,a
  120.     out.b a,d
  121.     out.b a,d
  122.     move.b b,a
  123.     out.b a,d
  124.     inc.b b
  125.     dbf .loop
  126.     move bp,c
  127.     xor.b b,b
  128. .loop    xor.b a,a
  129.     out.b a,d
  130.     move.b b,a
  131.     out.b a,d
  132.     inc.b b
  133.     move.b #63,a
  134.     out.b a,d
  135.     dbf .loop
  136.     move #8,c
  137.     xor.b a,a
  138. .loop    move.b b,a
  139.     out.b a,d
  140.     move.b #63,a
  141.     out.b a,d
  142.     out.b a,d
  143.     add.b #4,b
  144.     dbf .loop
  145.  
  146.     move bp,c
  147.     sub #8,c
  148.     move.b #8,b
  149. .loop    move.b b,a
  150.     out.b a,d
  151.     xor.b a,a
  152.     out.b a,d
  153.     move.b b,a
  154.     out.b a,d
  155.     inc.b b
  156.     dbf .loop
  157.     move bp,c
  158.     xor.b b,b
  159. .loop    move.b #63,a
  160.     out.b a,d
  161.     move.b b,a
  162.     out.b a,d
  163.     inc.b b
  164.     move.b #63,a
  165.     out.b a,d
  166.     dbf .loop
  167.     move #8,c
  168. .loop    move.b #63,a
  169.     out.b a,d
  170.     out.b a,d
  171.     out.b a,d
  172.     dbf .loop
  173.  
  174.  
  175. ; Initialize the 320* table
  176.  
  177.     move.l #multable,be
  178.     move #240,c
  179.     xor a,a
  180. .loop    move a,(be)
  181.     add #320,a
  182.     add.l #2,be
  183.     dbf .loop
  184.  
  185. ; Self-generate the vertical display routine
  186.  
  187.     move.l #realdraw,be
  188.     move #240,c
  189.     xor a,a
  190. .loop
  191. ;    move #$a788,(be)    ; move.b ah, ...
  192. ;    move #$a700,(be)    ; add.b ah, ...
  193. ;    move #$a708,(be)    ; or.b ah, ...
  194.     move #$a710,(be)    ; addx.b ah, ...
  195. ;    move #$a720,(be)    ; and.b ah, ...
  196. ;    move #$a730,(be)    ; xor.b ah, ...
  197.  
  198.     move a,2(be)        ; offset(b)
  199.     move #$c503,4(be)    ; add bp,a
  200.     add.l #6,be
  201.     add #320,a
  202.     dbf .loop
  203.  
  204. ; test polygon
  205.  
  206.     intoff
  207.  
  208. zeloop
  209. ;    bsr fade
  210.     bsr cpybck
  211.  
  212. happy1    move.l #0.l,ae
  213. happy2    move.l #10.l,be
  214. happy3    move.l #30.l,ce
  215.  
  216.     bsr initrotation
  217.  
  218.     inc happy1+2
  219.     and #511,happy1+2
  220.     inc happy2+2
  221.     and #511,happy2+2
  222.     add #3,happy3+2
  223.     and #511,happy3+2
  224.  
  225. ; Process objects
  226.  
  227.     move.l #object,sie
  228. pipi    move.l #points+2,die
  229.     move (sie),bp
  230.     test bp,bp
  231.     beq foune
  232.     move bp,-2(die)
  233.     add.l #2,sie
  234. .loop    move #160,rotatedx
  235.     move #100,rotatedy
  236.     move.l #sintable,be
  237.     xor.l ae,ae
  238.     move 6(sie),a
  239.     add #2,a
  240.     and #511,a
  241.     move a,6(sie)
  242.     move.l (be,ae*4),ae
  243.     asr.l #12-6,ae
  244.     add #64,a
  245.     move a,4(die)
  246.     movesx.l (sie),be
  247.     movesx.l 2(sie),ce
  248.     movesx.l 4(sie),de
  249.     push bp
  250.     push.l sie
  251.     move.l #!faraway,sie
  252.     bsr rotate
  253.     pop.l sie
  254.     pop bp
  255.     move rotatedx,a
  256.     move a,(die)
  257.     move rotatedy,a
  258.     move a,2(die)
  259.     add.l #8,sie
  260.     add.l #6,die
  261.     dec bp
  262.     bne.s .loop
  263.     move.l #points,be
  264.     bsr poly
  265.     bra pipi
  266. foune
  267.  
  268. ; Draw
  269.  
  270. ;    move #$3c8,d
  271. ;    xor.b a,a
  272. ;    out.b a,d
  273. ;    inc d
  274. ;    out.b a,d
  275. ;    out.b a,d
  276. ;    move.b #$31,a
  277. ;    out.b a,d
  278.  
  279. ;    bsr vsync
  280.     bsr cpyscrn
  281.  
  282. ;    move #$3c8,d
  283. ;    xor.b a,a
  284. ;    out.b a,d
  285. ;    inc d
  286. ;    out.b a,d
  287. ;    out.b a,d
  288. ;    out.b a,d
  289.  
  290. * Press [Escape] to logout !
  291.  
  292.         in.b #$60,a
  293.         cmp.b #129,a
  294.         bne zeloop
  295.  
  296.     bsr txtmode
  297.  
  298.     inton
  299.     move #$4c00,a
  300.     trap #$21
  301.  
  302. ; kassos
  303.  
  304.     rts
  305.  
  306. ; be : points addresses
  307.  
  308. poly    pusha.l
  309.     xor.l ae,ae
  310.     move (be),a        ; a : first element of the list
  311.     add.l #2,be
  312.     move.l be,!fone1
  313.     move.l be,!lone2
  314.  
  315.     add a,a
  316.     move a,bp
  317.     add bp,bp
  318.     add bp,a        ; *6 -> a : enda the list
  319.     add.l be,ae
  320.     sub.l #6,ae
  321.     move.l ae,!lone1
  322.     move.l ae,!fone2
  323.  
  324.     move -2(be),c
  325.  
  326.     move (be),bp        ; xmin = first
  327.     move.l be,sie        ; addrmin = first addr
  328. sort    move (be),a        ; x
  329.     cmp bp,a
  330.     bge.s poaplupti        ; zob
  331.     move a,bp        ; new xmin
  332.     move.l be,sie        ; new addy
  333. poaplupti
  334.     add.l #6,be
  335.     dbf sort        ; end of the sort loop. si = lefter item
  336.  
  337.     move.l sie,leftitem
  338.  
  339. ; Compute the first upper item
  340.  
  341.     move.l sie,bpe
  342.     bsr getnextitem
  343.     move.l sie,upitem
  344.  
  345. ; Compute the first lower item
  346.  
  347.     move.l bpe,sie
  348.     bsr getpreviousitem
  349.     move.l sie,downitem
  350.  
  351. ; Compute the left addy
  352.  
  353.     move.l leftitem,de
  354.     xor.l be,be
  355.     move 2(de),b
  356.     xor.l ae,ae
  357.     move (de),a
  358. ;    add.l #$a0000,ae
  359.     move.l ae,leftaddr
  360.  
  361. ; Compute and store the upper slope
  362.  
  363.     move.l leftitem,sie
  364.     move.l upitem,die
  365.     bsr getslope
  366.     move bp,upperslope
  367.     move a,uppershadeslope
  368.  
  369. ; Compute and store the lower slope
  370.  
  371.     move.l leftitem,sie
  372.     move.l downitem,die
  373.     bsr getslope
  374.     move bp,lowerslope
  375.     move a,lowershadeslope
  376.  
  377. ; Init uppery and lowery
  378.  
  379.     move.l leftitem,sie
  380.     move 2(sie),a
  381.     asl #8,a
  382.     move a,uppery
  383.     move a,lowery
  384.  
  385. ; Init uppershade and lowershade
  386.  
  387.     move 4(sie),a
  388.     asl #8,a
  389.     move a,uppershade
  390.     move a,lowershade
  391.  
  392. ; Get the horizontally shorter item
  393.  
  394.     move #0,alreadydone
  395.  
  396. snacker
  397.     move.l upitem,ae
  398.     move (ae),d
  399.     move.l downitem,ae
  400.     move (ae),b
  401.     move d,c        ; up first by default
  402.     move.b #0,dsk
  403.     cmp b,d
  404.     ble.s upfirst
  405.     move b,c
  406.     move.b #1,dsk
  407. upfirst    move.l leftitem,ae
  408.     sub (ae),c        ; c = width of the current segment
  409.     move.l #alreadydone,be
  410.     sub (be),c
  411.     add c,(be)
  412.  
  413. ; Draw the bizness
  414.  
  415.     xor a,a
  416.     move a,gs
  417.  
  418.     test c,c
  419.     ble.s breakit
  420.  
  421. .loop    move.l #multable,sie
  422.     move.l curaddr,be
  423.     move uppery,a
  424.     xor.l de,de
  425.     move.b ah,d
  426.     move d,staxy
  427.     move (sie,de*2),d
  428.     add.l de,be
  429.     move.l be,segmentup
  430.  
  431.     move.l curaddr,be
  432.     move lowery,a
  433.     xor.l de,de
  434.     move.b ah,d
  435.     move d,staxy2
  436.     move (sie,de*2),d
  437.     add.l de,be
  438.     move.l be,segmentdown
  439.  
  440.     bsr drawsegment
  441.     inc.l curaddr
  442.  
  443. breakit    move upperslope,a
  444.     add a,uppery
  445.     move lowerslope,a
  446.     add a,lowery
  447.     move uppershadeslope,a
  448.     add a,uppershade
  449.     move lowershadeslope,a
  450.     add a,lowershade
  451.     dec c
  452.     bgt .loop
  453.  
  454. ; If both segments converged to the same point, then the polygon is completed
  455.  
  456.     move.l upitem,a
  457.     cmp.l downitem,a
  458.     beq yoopikassos
  459.  
  460. ; Next point
  461.  
  462.     move.b dsk,a
  463.     test.b a,a        ; 0 = up
  464.     bne downstairs
  465.  
  466. ; Snap the upper part
  467.  
  468.     move.l upitem,sie
  469.     push.l sie
  470.     bsr getnextitem
  471.     move.l sie,upitem
  472.     move.l sie,ae
  473.  
  474.     pop.l sie
  475.     move.l ae,die
  476.     bsr getslope
  477.     move bp,upperslope
  478.     move a,uppershadeslope
  479.  
  480.     bra snacker
  481.  
  482. downstairs
  483.  
  484.     move.l downitem,sie
  485.     push.l sie
  486.     bsr getpreviousitem
  487.     move.l sie,downitem
  488.     move.l sie,ae
  489.  
  490.     pop.l sie
  491.     move.l ae,die
  492.     bsr getslope
  493.     move bp,lowerslope
  494.     move a,lowershadeslope
  495.  
  496.     bra snacker
  497.  
  498. yoopikassos
  499.     popa.l
  500.     rts
  501.  
  502. ; Draw a gouraud segment
  503.  
  504. drawsegment
  505.  
  506.     pusha.l
  507.  
  508.     xor.l ce,ce
  509.     move staxy2,c
  510.     sub staxy,c
  511.     ble.s topdelire
  512. xtazy
  513.     move.l segmentup,be
  514.  
  515.     move.l ce,bpe
  516.     move lowershade,a
  517.     sub uppershade,a
  518.     beq.s pipe
  519.     ext.l
  520.     ext.q
  521.     idiv.l bpe
  522. pipe
  523.     move a,bp
  524.     move uppershade,a
  525.  
  526.     add c,c
  527.     move c,d
  528.     add c,c
  529.     add d,c            ; *6
  530.     move.l #realdraw+4,sie
  531.     add.l ce,sie
  532.     move.b (sie),c
  533.     move.b #$c3,(sie)    ; Move the 'rts'
  534.     push ds
  535.     move cs,d
  536.     add #@pchouk,d
  537. ;    move #$a000,d
  538.     move d,ds
  539.     bsr realdraw
  540.     pop ds
  541.  
  542.     move.b c,(sie)
  543.  
  544. topdelire
  545.     popa.l
  546.     rts
  547.  
  548. ; Various datas
  549.  
  550.     align.l
  551. leftitem
  552.     dc.l 0
  553. upitem    dc.l 0
  554. downitem
  555.     dc.l 0
  556. curaddr
  557. leftaddr
  558.     dc.l 0
  559. segmentup
  560.     dc.l 0
  561. segmentdown
  562.     dc.l 0
  563. upperslope
  564.     dc.w 0
  565. lowerslope
  566.     dc.w 0
  567. uppery    dc.w 0
  568. lowery    dc.w 0
  569. dsk    dc.w 0
  570. alreadydone
  571.     dc.w 0
  572. staxy    dc.w 0
  573. staxy2    dc.w 0
  574. uppershadeslope
  575.     dc.w 0
  576. lowershadeslope
  577.     dc.w 0
  578. uppershade
  579.     dc.w 0
  580. lowershade
  581.     dc.w 0
  582.  
  583. ; Get the left xtrem of a segment in (sie), the right one in (die),
  584. ; computes the slope and returns it in bp
  585. ; The shading step is also computed and returns in ae
  586.  
  587. getslope
  588.     move 2(die),a
  589.     sub 2(sie),a
  590.     ext.l
  591.     ext.q
  592.     asl.l #8,ae
  593.     xor.l be,be
  594.     move (die),b
  595.     sub (sie),b
  596.     beq.s exitslp
  597.     idiv.l be        ; ae# = (y2#-y1#)/(x2#-x1#)
  598. exitslp
  599.     move a,bp
  600. onslp
  601.  
  602. ; Compute the shading
  603.  
  604.     move 4(die),a
  605.     sub 4(sie),a
  606.     ext.l
  607.     ext.q
  608.     asl.l #8,ae
  609.     xor.l be,be
  610.     move (die),b
  611.     sub (sie),b
  612.     beq.s exitslp2
  613.     idiv.l be        ; ae# = (s2#-s1#)/(x2#-x1#)
  614.  
  615. exitslp2
  616.     rts
  617.  
  618. ; Takes sie, find the previous item and put it anew to sie
  619.  
  620. getpreviousitem
  621.  
  622. .tmp    cmp.l #'ideJ',sie    ; first one ?
  623. !fone1    set .tmp+3
  624.     bne.s nomod1
  625. .tmp    move.l #'ideJ',sie    ; -> last one
  626. !lone1    set .tmp+2
  627.     bra.s endmod1
  628. nomod1    sub.l #6,sie        ; previous one
  629. endmod1
  630.     rts
  631.  
  632. ; Take sie, find the next item and put it anew to sie
  633.  
  634. getnextitem
  635.  
  636. .tmp    cmp.l #'ideJ',sie    ; last one ?
  637. !fone2    set .tmp+3
  638.     bne.s nomod2
  639. .tmp    move.l #'ideJ',sie    ; -> first one
  640. !lone2    set .tmp+2
  641.     bra.s endmod2
  642. nomod2    add.l #6,sie        ; next one
  643. endmod2
  644.     rts
  645.  
  646.     include frm.si
  647.  
  648. ; Sample objects. Format is :
  649. ; - number of points
  650. ; - x, y, lightshade
  651. ; .points are ignored
  652.  
  653. object
  654.     dc.w 4
  655.     dc.w 0-64+16,64-16,0-64+16,0
  656.     dc.w 0-64+16,0-64+16,0-64+16,90
  657.     dc.w 64-16,0-64+16,0-64+16,180
  658.     dc.w 64-16,64-16,0-64+16,270
  659.  
  660.     dc.w 4
  661.     dc.w 0-64+16,64-16,64-16,71
  662.     dc.w 0-64+16,0-64+16,64-16,250
  663.     dc.w 0-64+16,0-64+16,0-64+16,90
  664.     dc.w 0-64+16,64-16,0-64+16,0
  665.  
  666.     dc.w 4
  667.     dc.w 64-16,64-16,0-64+16,270
  668.     dc.w 64-16,0-64+16,0-64+16,180
  669.     dc.w 64-16,0-64+16,64-16,90
  670.     dc.w 64-16,64-16,64-16,30
  671.  
  672.     dc.w 4
  673.     dc.w 0-64+16,0-64+16,0-64+16,90
  674.     dc.w 0-64+16,0-64+16,64-16,250
  675.     dc.w 64-16,0-64+16,64-16,90
  676.     dc.w 64-16,0-64+16,0-64+16,180
  677.  
  678.     dc.w 4
  679.     dc.w 0-64+16,64-16,64-16,71
  680.     dc.w 0-64+16,64-16,0-64+16,0
  681.     dc.w 64-16,64-16,0-64+16,270
  682.     dc.w 64-16,64-16,64-16,30
  683.  
  684. ; Second object
  685.  
  686.     dc.w 4
  687.     dc.w -64,64,-64,0+16
  688.     dc.w -64,-64,-64,90+16
  689.     dc.w 64,-64,-64,180+16
  690.     dc.w 64,64,-64,270+16
  691.  
  692.     dc.w 4
  693.     dc.w -64,64,64,71+16
  694.     dc.w -64,-64,64,250+16
  695.     dc.w -64,-64,-64,90+16
  696.     dc.w -64,64,-64,0+16
  697.  
  698.     dc.w 4
  699.     dc.w 64,64,-64,270+16
  700.     dc.w 64,-64,-64,180+16
  701.     dc.w 64,-64,64,90+16
  702.     dc.w 64,64,64,30+16
  703.  
  704.     dc.w 4
  705.     dc.w -64,-64,-64,90+16
  706.     dc.w -64,-64,64,250+16
  707.     dc.w 64,-64,64,90+16
  708.     dc.w 64,-64,-64,180+16
  709.  
  710.     dc.w 4
  711.     dc.w -64,64,64,71+16
  712.     dc.w -64,64,-64,0+16
  713.     dc.w 64,64,-64,270+16
  714.     dc.w 64,64,64,30+16
  715.  
  716.     dc.w 0
  717.  
  718. points    dc.w 0
  719.     dc.w 0,0,0
  720.     dc.w 0,0,0
  721.     dc.w 0,0,0
  722.     dc.w 0,0,0
  723.  
  724. ; Sinus tables
  725.  
  726.     align.l
  727. sintable
  728.     incbin sintable.sct
  729. .costable    set sintable+128*4
  730.  
  731.     align.l
  732.  
  733. rots1    dc.l 0
  734. rotc1    dc.l 0
  735. rots2    dc.l 0
  736. rotc2    dc.l 0
  737. rots3    dc.l 0
  738. rotc3    dc.l 0
  739. rotj    dc.l 0
  740. rotk    dc.l 0
  741. rotl    dc.l 0
  742. rotm    dc.l 0
  743. rotd    dc.l 0
  744. rotg    dc.l 0
  745. rote    dc.l 0
  746. roth    dc.l 0
  747. rota    dc.l 0
  748. rotb    dc.l 0
  749.  
  750. rotatedx
  751.     dc.l 0
  752. rotatedy
  753.     dc.l 0
  754.  
  755. ; 3D Rotations - Initialize the vectorial base
  756. ; ae = xrot   be = yrot   ce = zrot
  757.  
  758. initrotation
  759.     move.l #sintable,sie
  760.     move.l #.costable,die
  761.     move.l (sie,ae*4),de
  762.     move.l de,rots1
  763.     move.l (die,ae*4),de
  764.     move.l de,rotc1
  765.     move.l (sie,be*4),de
  766.     move.l de,rots2
  767.     move.l (die,be*4),de
  768.     move.l de,rotc2
  769.     move.l (sie,ce*4),de
  770.     move.l de,rots3
  771.     move.l (die,ce*4),de
  772.     move.l de,rotc3
  773.  
  774.     move.l rots3,be
  775.     move.l rotc1,ae
  776.     move.l ae,ce        ; c = c1
  777.     imul.l be,ae
  778.     asr.l #12,ae
  779.     move.l ae,rotj
  780.  
  781.     move.l rots1,ae
  782.     move.l ae,bpe        ; bp = s1
  783.     imul.l be,ae
  784.     asr.l #12,ae
  785.     move.l ae,rotk
  786.  
  787.     move.l rotc3,de
  788.     move.l ce,ae
  789.     imul.l de,ae
  790.     asr.l #12,ae
  791.     move.l ae,rotl
  792.  
  793.     move.l bpe,ae
  794.     imul.l de,ae
  795.     asr.l #12,ae
  796.     move.l ae,rotm
  797.  
  798.     move.l rots2,be        ; b = s2
  799.     imul.l be,ae        ; a = m*s2
  800.     asr.l #12,ae
  801.     sub.l rotj,ae
  802.     move.l ae,rotd
  803.  
  804.     move.l rotl,ae
  805.     move.l ae,bpe        ; bp = l
  806.     imul.l be,ae        ; a = l*s2
  807.     asr.l #12,ae
  808.     move.l rotk,ce        ; c = k
  809.     add.l ce,ae
  810.     move.l ae,rotg
  811.  
  812.     move.l ce,ae
  813.     imul.l be,ae
  814.     asr.l #12,ae
  815.     add.l bpe,ae
  816.     move.l ae,rote
  817.  
  818.     move.l rotj,ae
  819.     imul.l be,ae
  820.     asr.l #12,ae
  821.     sub.l rotm,ae
  822.     move.l ae,roth
  823.  
  824.     move.l rotc2,be        ; b = c2
  825.     move.l rotc3,ae
  826.     imul.l be,ae
  827.     asr.l #12,ae
  828.     move.l ae,rota
  829.  
  830.     move.l rots3,ae
  831.     imul.l be,ae
  832.     asr.l #12,ae
  833.     move.l ae,rotb
  834.  
  835.     rts
  836.  
  837. ; According to the previously calculated vectorial base, project
  838. ; a 3D couple of points on the 2D screen plane
  839. ; be = x   ce = y   de = z   sie = zdep
  840. ; Results addad to (rotatedx) and (rotatedy)
  841.  
  842. rotate
  843.     move.l rota,bpe
  844.     imul.l be,bpe
  845.     move.l rotd,ae
  846.     imul.l ce,ae
  847.     add.l ae,bpe
  848.     move.l rotg,ae
  849.     imul.l de,ae
  850.     add.l ae,bpe
  851.     move.l sie,ae
  852.     imul.l bpe,ae
  853.     asr.l #12+10,ae
  854.     add.l ae,rotatedx
  855.  
  856.     move.l rotb,bpe
  857.     imul.l be,bpe
  858.     move.l rote,ae
  859.     imul.l ce,ae
  860.     add.l ae,bpe
  861.     move.l roth,ae
  862.     imul.l de,ae
  863.     add.l ae,bpe
  864.     move.l sie,ae
  865.     imul.l bpe,ae
  866.     asr.l #12+10,ae
  867.     add.l ae,rotatedy
  868.  
  869.     rts
  870.  
  871. cpybck
  872.     push ds
  873.     push es
  874.  
  875.     move cs,a
  876.     add #@pchouk,a
  877.     move a,es
  878.     move cs,a
  879.     add #@bkg,a
  880.     move a,ds
  881.     xor si,si
  882.     xor di,di
  883.     move #320*200/4,c
  884.     rep:moves.l
  885.  
  886.     pop es
  887.     pop ds
  888.  
  889.     rts
  890.  
  891. fade
  892.     push ds
  893.     push es
  894.  
  895.     move cs,a
  896.     add #@pchouk,a
  897.     move a,ds
  898.     xor b,b
  899.     assume pchouk
  900.     move.l #fadetable,sie
  901.     assume START
  902.  
  903.     move #320*200,c
  904.     xor.l ae,ae
  905. .loop    move.b 320(b),a
  906.     move.b (sie,ae),a
  907.     move.b a,(b)
  908.     inc b
  909.     dec c
  910.     bne.s .loop
  911.  
  912.     pop es
  913.     pop ds
  914.  
  915.     rts
  916.  
  917. cpyscrn
  918.     push ds
  919.     push es
  920.  
  921.     move #$a000,a
  922.     move a,es
  923.     move cs,a
  924.     add #@pchouk,a
  925.     move a,ds
  926.     xor si,si
  927.     xor di,di
  928.     move #320*200/2,c
  929.     rep:moves.w
  930.  
  931.     pop es
  932.     pop ds
  933.  
  934.     rts
  935.  
  936.     include xymode.si
  937.  
  938.     section bss
  939.  
  940. ; Self-generated code to draw a vertical shaded line
  941.  
  942. realdraw
  943.     ds.w 6*240/2        ; Generated at the beginning of the code
  944.     rts            ; Just for fun and security
  945.  
  946. multable
  947.     ds.w 240        ; 240 in case of a 320x240 resolution
  948.  
  949.     segment
  950. pchouk    ds.l 320*240/4
  951. pchoukf
  952.     align.l
  953. fadetable
  954.     ds.b 256
  955.     segment
  956. bkg    ds.l 320*240/4
  957.     segment
  958.     ds.l 512
  959. stack
  960.